' ***********************************************************************
' Assembly         : Ioc
' Author           : Tim Ford
' Created          : 10-02-2013
'
' Last Modified By : Tim Ford
' Last Modified On : 10-02-2013
' ***********************************************************************
' <copyright file="IocConfigurationContainer.vb" company="Red Baron Solutions">
'     Red Baron Solutions. All rights reserved.
' </copyright>
' <summary></summary>
' ***********************************************************************

Namespace Ioc.Configuration
    ''' <summary>
    ''' 	
    ''' </summary>
    Public NotInheritable Class IocConfigurationContainer
        Private Shared ReadOnly m_LockingObject As New Object()



        ''' <summary>
        ''' Gets the app settings.	
        ''' </summary>
        ''' <value></value>
        ''' <remarks></remarks>
        <System.Diagnostics.DebuggerNonUserCode> _
        Public Shared ReadOnly Property AppSettings() As List(Of IocContainerElements)
            Get
                SyncLock m_LockingObject
                    If Not m_Loaded Then
                        m_Loaded = True
                        m_Settings = New IocSettingsSectionCollection()
                        m_Settings.GetSettings()
                    End If
                End SyncLock
                Return DirectCast(m_Settings, List(Of IocContainerElements))
            End Get
        End Property
        Private Shared m_Settings As IocSettingsSectionCollection
        Private Shared m_Loaded As Boolean



#Region "Private shiSettingsSection Class"
        Private Class IocSettingsSectionCollection
            Inherits List(Of IocContainerElements)
            Public Sub New()

            End Sub
            Public Sub New(ByVal capacity As Integer)
                MyBase.New(capacity)

            End Sub
            Public Sub New(ByVal collection As IEnumerable(Of IocContainerElements))
                MyBase.New(collection)

            End Sub

            <System.Diagnostics.DebuggerNonUserCode> _
            Public Sub GetSettings()
                'If the settings collection is not populated, populate it.
                If MyBase.Count = 0 Then

                    Dim configSettings As IocConfiguration = IocConfiguration.GetConfig()

                    'Only populate if the section exists.
                    If configSettings IsNot Nothing Then

                        For i As Integer = 0 To configSettings.Container.Count - 1
                            MyBase.Add(configSettings.Container(i))

                        Next
                    End If


                End If
            End Sub

        End Class
#End Region
    End Class
End Namespace


